<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>localStorage</title>
    <script type="text/javascript">
        let p = {"name":'张三',age:18};
        function saveData(){
            localStorage.setItem('mykey','myValue');
            localStorage.setItem('person',JSON.stringify(p));
        }
        function readData(){
            console.log(localStorage.getItem('mykey'));
            console.log(localStorage.getItem('person'));
        }
        function deleteData(){
            localStorage.removeItem('mykey');
            localStorage.removeItem('person');
        }
    </script>
</head>

<body>
<h2>localStorage</h2>
<button onclick="saveData()">点我保存数据</button>
<button onclick="readData()">点我读取数据</button>
<button onclick="deleteData()">点我删除数据</button>
</body>

</html>